package org.nowcoder.leetcode.greedy;

import java.util.Arrays;

/**
 * Title  : 455. Assign Cookies
 * Source : https://leetcode.cn/problems/assign-cookies/description/
 * Author : XrazYang
 * Date   : 2023-10-23
 */

public class LeetCode_455 {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        int i = 0, k = 0;
        while (i < g.length && k < s.length) {
            for (int j = k; j < s.length; j++) {
                if (g[i] <= s[j]) {
                    count++;
                    k = j + 1;
                    break;
                }
            }
            i++;
        }
        return count;
    }
}
